home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / By the Book / Mac Pascal Primer, 4.0 / Chap 3, ShowPict ƒ / ShowPict.p next >
Text File  |  1990-06-27  |  1KB  |  59 lines

  1. program ShowPICT;
  2.     const
  3.         BASE_RES_ID = 400;
  4.  
  5.     var
  6.         gPictureWindow: WindowPtr;
  7.  
  8.  
  9. {-------------------------------->    CenterPict    <---}
  10.  
  11.     procedure CenterPict (thePicture: PicHandle; var myRect: Rect);
  12.         var
  13.             windRect, pictureRect: Rect;
  14.     begin
  15.         windRect := myRect;
  16.         pictureRect := thePicture^^.picFrame;
  17.         myRect.top := (windRect.bottom - windRect.top - (pictureRect.bottom - pictureRect.top)) div 2 + windRect.top;
  18.         myRect.bottom := myRect.top + (pictureRect.bottom - pictureRect.top);
  19.         myRect.left := (windRect.right - windRect.left - (pictureRect.right - pictureRect.left)) div 2 + windRect.left;
  20.         myRect.right := myRect.left + (pictureRect.right - pictureRect.left);
  21.     end;
  22.  
  23.  
  24. {-------------------------------->    DrawMyPicture    <---}
  25.  
  26.     procedure DrawMyPicture (pictureWindow: WindowPtr);
  27.         var
  28.             myRect: Rect;
  29.             thePicture: PicHandle;
  30.     begin
  31.         myRect := pictureWindow^.portRect;
  32.  
  33.         thePicture := GetPicture(BASE_RES_ID);
  34.  
  35.         CenterPict(thePicture, myRect);
  36.         DrawPicture(thePicture, myRect);
  37.     end;
  38.  
  39.  
  40. {-------------------------------->    WindowInit    <---}
  41.  
  42.     procedure WindowInit;
  43.     begin
  44.         gPictureWindow := GetNewWindow(BASE_RES_ID, nil, WindowPtr(-1));
  45.         ShowWindow(gPictureWindow);
  46.         SetPort(gPictureWindow);
  47.     end;
  48.  
  49.  
  50. {-------------------------------->    ShowPICT    <---}
  51.  
  52. begin
  53.     WindowInit;
  54.     DrawMyPicture(gPictureWindow);
  55.  
  56.     while (not Button) do
  57.         begin
  58.         end;
  59. end.